from django.http import HttpResponse
from django.shortcuts import render, redirect


# Create your views here.


def index(request):
    context = {
        'city': '北京',
        "temperature": 20,
        'alist': ('春', '夏', '秋', '冬'),
        'adict': {'name': "西游记", 'author': "吴承恩"}

    }
    return render(request, 'template_index.html', context)


def weather(request):
    # 直接返回模板页面
    context = {"city": "深圳", "temperature": 20}
    return render(request, 'template_weather.html', context)


def hero_list(request):
    """人物列表"""
    heros = [{'age': 19, 'name': '关羽'}, {'age': 18, 'name': '张飞'},
             {'age':22, 'name': '刘备'}, {'age': 36, 'name': '曹操'}]
    # heros=None
    context = {'heros': heros,'num':50}
    return render(request,'template_hero_list.html',context)

def filter(request):
    context={
        'data':10,
        'data_list1':['春','夏'],
        'data_list2':['秋','冬'],
        'data_str':'django'

    }
    return render(request, 'template_filter.html', context)


def base(request):

    return redirect('https://www.baidu.com')
    # return render(request,'base.html')

